/**
 * Created by Administrator on 2017/4/25.
 */
var Tooltip = require('../../../../src/libs/tooltip');
var Progress = require('../../../../src/libs/progress');
var InvestAction = require('../investAction');
var ProjectList = React.createClass({
    getDefaultProps:function(){
        return{
            projectList: []
        }
    },
    render:function(){
        var _this = this;
        return(
            <div className="project-list clearfix" ref="project-list">
                {
                    _this.props.projectList.length > 0 ? (
                        _this.props.projectList.map(function(item,index){
                            //投资动作Props
                            var actionData = {
                                minFlag:item.minFlag?item.minFlag:true,
                                flag:{
                                    login:item.login,
                                    loginUrl:item.loginUrl?item.loginUrl:"",
                                    confirmUrl:item.confirmUrl?item.confirmUrl:"",
                                    ProjectStatus:item.ProjectStatus?item.ProjectStatus:"",
                                    JMBeginTime:item.JMBeginTime?item.JMBeginTime:"",
                                    ProjectBeginTime:item.ProjectBeginTime?item.ProjectBeginTime:""
                                }
                            };
                            /*项目规模*/
                            var total_amount = Number(item.TotalAmount);
                            if(total_amount < 10000){
                                total_amount = UFormatter.formatMoney(total_amount,2) + '元';
                            }else{
                                total_amount = UFormatter.formatMoney(total_amount/10000,2) + '万元';
                            }
                            /*活动标志*/
                            var Aflag_Icon = item.Aflag_Icon;
                            var arr_aflag, resetAflag = [];
                            if(Aflag_Icon){
                                arr_aflag = Aflag_Icon.split(',');
                                for(var i = 0;i < arr_aflag.length;i++){
                                    resetAflag.push(arr_aflag[i].split('|'));
                                }
                            }

                            return (
                                <div className="item">
                                    <h3>
                                        <a href={item.confirmUrl}>{item.ProjectName?item.ProjectName:""}</a>
                                        {item.IsExclusive?
                                            (item.IsExclusivePublic?
                                                <Tooltip className="bg-icon tag tag-zhuang" title="专属项目，需输入项目专属识别码才可投标"></Tooltip> :
                                                <span className="bg-icon tag tag-zhuang"></span>)
                                            :""
                                        }
                                        {resetAflag ?
                                            resetAflag.map(function(v,j){
                                                var _src = "../content/images/ActImage/"+v[0];
                                                if(v[1]){
                                                    return <Tooltip title={v[1]} className="tag"><img src={_src}/></Tooltip>
                                                }else{
                                                    return <span href="javascript:void(0)" className="tag"><img src={_src}/></span>
                                                }
                                            }) : ""
                                        }
                                    </h3>
                                    <ul>
                                        <li className="col-1">{item.Interest?(<span className="fc-main fs18"><b>{item.Interest}</b>%</span>):""}{item.Interest?(<span className="fc-light"> 年化收益率</span>):""}</li>
                                        <li className="col-2">{item.Duration?(<span className="fc-dark fs20">{item.Duration+"天"}</span>):""}{item.Duration?(<span className="fc-light"> 项目期限</span>):""}</li>
                                        <li className="col-3">{item.TotalAmount?(<span className="fc-dark fs20">{total_amount}</span>):""}{item.TotalAmount?(<span className="fc-light"> 项目规模</span>):""}</li>
                                        <li className="col-4">
                                            {item.Progress?(<Progress className="progress" type="line" percent={item.Progress}></Progress>):""}
                                            {item.MinAmount?(<p>{item.MinAmount}元起投</p>):""}
                                        </li>
                                        <li className="col-5">
                                            <InvestAction data={actionData}/>
                                        </li>
                                    </ul>
                                    <div className="clear"></div>
                                </div>
                            )
                        })
                    ):(<div className="nodata">项目正在筹备中，敬请期待！</div>)
                }
            </div>
        )
    }
});
module.exports = ProjectList;